var HyvesBridge = {}, hyvesAuthWin, swfId;

HyvesBridge.available = function() {
	return true;
};

HyvesBridge.setFlashElement = function(id) {
    swfId = id;
};

HyvesBridge.callAuthorize = function(url) {
    hyvesAuthWin = window.open(url, "hyvesAuthWin", "width=780, height=500");
};

HyvesBridge.verify = function() {
	
	var location = window.location.href;
	
	var token = decodeURIComponent(location.split("oauth_token=")[1].split("&oauth_verifier=")[0]);
	var verifier = decodeURIComponent(location.split("&oauth_verifier=")[1]);
	
	window.opener.HyvesBridge.passToken(token, verifier);
	window.close();
};

HyvesBridge.passToken = function(token, verifier) {
	if (!swfId) {
		alert("You never called HyvesBridge.setFlashElement!");
	} else {
        flash = document.getElementById(swfId);
        flash.setToken(token, verifier); 
    }
};
